package com.mon4cc.simulation.dataranger;

import org.springframework.util.Assert;

import java.util.*;

/**
 * @author Ping
 * @date 2022/12/20 16:40
 **/
public class EnumerateRanger implements DataRanger {
    private List<String> values ;
    private Random rand = new Random(System.currentTimeMillis()) ;

    public EnumerateRanger(String ... vals) {
        Assert.state(vals.length>0, "The values for enumerate data ranges should be not empty.");
        values = new ArrayList<>() ;
        Collections.addAll(values, vals) ;
    }

    @Override
    public Object nextValue() {
        return values.get(rand.nextInt(values.size()));
    }
}
